package com.t235.gc.biz.controller;

import com.t235.gc.AjaxResult;
import com.t235.gc.biz.service.GoodsService;
import com.t235.gc.mapper.UsersMapper;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

//1
@RestController
@Slf4j
@Api
public class DemoController {
    @Resource
    private UsersMapper usersMapper;
    @Autowired
    GoodsService goodsService;
    @GetMapping("/hello")//2323
    public AjaxResult hello() {
        return AjaxResult.success("hello world " + usersMapper.selectByPrimaryKey(1201581319114785L).getNickname());
    }
    @GetMapping("/api/partners/admin/getPartnersList")
    public AjaxResult hello1() {
        return AjaxResult.success("hello world " + usersMapper.selectByPrimaryKey(1201581319114785L).getNickname());
    }

    @GetMapping("/code")
    public void code(HttpServletResponse response) throws IOException {
        String uri = "https://gitee.com/oauth/authorize?client_id=842c04b2fa8c1db3556674f913eacbc580dfb2a6d2a3403c5bf96943f66b50ed&redirect_uri=http%3A%2F%2Fcz69qr.natappfree.cc%2Fcallback&response_type=code";
        log.info("uri:{}", uri);
        response.sendRedirect(uri);
    }

    @RequestMapping("/callback")
    public void callback(String code) {
        log.info("code:{}",code);
    }

    public static void main(String[] args) {
        SimpleDateFormat sj2 = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String format = sj2.format(date);
        System.out.println(format);
    }
}
